﻿
using System ;
using System.Windows.Forms ;

using MskEdit.Dxf.Model ;


namespace MskEdit.Dxf.Frontend
{

    public class DxfTablesTreeNode : TreeNode 
    {
        private DxfTables dxfTables_ ;
        
        
        public static DxfTablesTreeNode TryFrom( DxfTables dxfTables, DxfTablesTreeNode fallbackValue ) {
        
            if ( dxfTables == null )
                return fallbackValue ;
                
            return new DxfTablesTreeNode( dxfTables ) ;
        }
        
        
        public DxfTablesTreeNode( DxfTables dxfTables ) {
        
            dxfTables_ = dxfTables ;
            this.Text = "Tables " ;
                
            foreach ( var dxfTable in dxfTables_.Tables ) {
                
                DxfTableTreeNode dxfTableTreeNode = DxfTableTreeNode.TryFrom( dxfTable, null ) ;
                if ( dxfTableTreeNode == null )
                    continue ;
                    
                this.Nodes.Add( dxfTableTreeNode ) ;
            }
        }
    }
}
